package unimelb.discussiontracker.twitter.data.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

@Entity
@Table(name = "TweetRanking")
@NamedQueries(value = {
        @NamedQuery(name = "TweetRanking.CountTopRankings", query = "SELECT COUNT(ranking) FROM TweetRanking ranking WHERE ranking.type = :rankType AND ranking.topic.id = :topicId AND ranking.interval.id = :intervalId"),
        @NamedQuery(name = "TweetRanking.CountRankingsForTag", query = "SELECT COUNT(ranking) FROM TweetRanking ranking JOIN ranking.tweet tweet JOIN tweet.hashTags tagAssoc WHERE ranking.type = :rankType AND ranking.topic.id = :topicId AND ranking.interval.id = :intervalId AND tagAssoc.hashTag.id = :tagId"),
        @NamedQuery(name = "TweetRanking.CountRankingsForUser", query = "SELECT COUNT(ranking) FROM TweetRanking ranking JOIN ranking.tweet tweet JOIN tweet.owner user WHERE ranking.type = :rankType AND ranking.topic.id = :topicId AND ranking.interval.id = :intervalId AND user.id = :userId"),
        @NamedQuery(name = "TweetRanking.FindByTweetTopicAndIntervalId", query = "SELECT ranking FROM TweetRanking ranking WHERE ranking.type = :rankType AND ranking.tweet.id = :tweetId AND ranking.topic.id = :topicId AND ranking.interval.id = :intervalId") })
public class TweetRanking {
    @Id
    @GeneratedValue
    @Column(name = "Id")
    private long id;

    @ManyToOne
    @JoinColumn(name = "TopicId")
    private TopicEntity topic;

    @ManyToOne
    @JoinColumn(name = "IntervalId")
    private IntervalEntity interval;

    @ManyToOne
    @JoinColumn(name = "TweetId")
    private TweetEntity tweet;

    @Column(name = "Strength")
    private int strength;

    @Column(name = "Sentiment")
    private int sentiment;

    @Enumerated(EnumType.STRING)
    @Column(name = "Type")
    private RankType type;

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public TopicEntity getTopic() {
        return topic;
    }

    public void setTopic(TopicEntity topic) {
        this.topic = topic;
    }

    public IntervalEntity getInterval() {
        return interval;
    }

    public void setInterval(IntervalEntity interval) {
        this.interval = interval;
    }

    public TweetEntity getTweet() {
        return tweet;
    }

    public void setTweet(TweetEntity tweet) {
        this.tweet = tweet;
    }

    public int getStrength() {
        return strength;
    }

    public void setStrength(int strength) {
        this.strength = strength;
    }

    public int getSentiment() {
        return sentiment;
    }

    public void setSentiment(int sentiment) {
        this.sentiment = sentiment;
    }

    public RankType getType() {
        return type;
    }

    public void setType(RankType type) {
        this.type = type;
    }

}
